package com.homework.homework2;import java.net.InetSocketAddress;import java.nio.ByteBuffer;import java.nio.channels.SocketChannel;/** * Created by aa on 2018/11/14. */public class ClientReceivce {    public static void main(String[] args) {        try{            SocketChannel sc = SocketChannel.open();            sc.socket().bind(new InetSocketAddress(3377));            sc.connect(new InetSocketAddress("127.0.0.1",8888));            ByteBuffer bb = ByteBuffer.allocate(1024);            while (true){                bb.clear();                sc.read(bb);                System.out.println(new String(bb.array(),0,bb.position()));            }        }catch (Exception e){            e.printStackTrace();        }    }}